Skip to content

ci: use a read-only token in the CI workflows - #20901

Open
amaechler wants to merge 4 commits into
apache:masterfrom
amaechler:ci-read-only-token
Open

amaechler wants to merge 4 commits into
apache:masterfrom
amaechler:ci-read-only-token

Conversation

@amaechler

@amaechler amaechler commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Description

Follow-up to #20878, from this discussion and this one.

This PR adds a few read-only permissions block, so pushes to master and release branches and scheduled runs get a scoped token (instead of write-all). Check this table for details:

Workflow Job Permissions Why
CI (ci.yml) top level, quality-gate contents: read quality-gate only reads needs
CI ci (calls ci-jobs.yml) contents: read, pull-requests: read A called workflow can only narrow what the calling job grants, so the caller must pass what changes needs
CI actions-timeline actions: read Kesin11/actions-timeline reads the workflow run and lists its jobs
CI jobs (ci-jobs.yml) top level, all worker and docker jobs contents: read checkout; caches and artifacts use the runner's own token
CI jobs changes contents: read, pull-requests: read dorny/paths-filter lists a pull request's files through the API; push events use checkout
Worker (worker.yml) execute contents: read mikepenz/action-junit-report runs with annotate_only: true, job_summary: false and no comment, so it creates no check run and makes no API call. No run: step, including the JaCoCo coverage report, is given the token
Docker Tests (docker-tests.yml) run-docker-tests contents: read checkout and upload-artifact only
Cron Job ITs (cron-job-its.yml) security_vulnerabilities contents: read checkout; the NVD and OSS Index credentials are separate secrets
PR Commit Checks (pr-checks.yml) conventional-commits pull-requests: read amannn/action-semantic-pull-request reads the pull request through the API; no checkout
Stale bot (stale.yml) stale actions: write, issues: write, pull-requests: write labels, comments on and closes issues and PRs; lists and deletes its state cache through the API

backport.yml, codeql.yml, labeler.yml, labeler-signal.yml and pr-merged.yml already declare their permissions and are unchanged.

Both the caller and the called workflows declare a block, and a future job added to ci-jobs.yml or worker.yml starts read-only even if a new caller forgets to restrict it. See Reusing workflow configurations: permissions passed from the caller "can be only downgraded (not elevated) by the called workflow".


This PR has:

  • been self-reviewed.

Pushes to master and release branches, and scheduled runs, got a write-all
GITHUB_TOKEN because these workflows had no permissions block. Give each
workflow a top-level block and widen it per job only where needed:

- CI, CI jobs, Worker, Docker tests, Cron Job ITs: contents: read
- changes (ci.yml) and the calling ci job: also pull-requests: read, for
  dorny/paths-filter to list a pull request's files through the API
- actions-timeline: actions: read, to list the run's jobs
- PR Commit Checks: pull-requests: read, for the PR title check
- Stale bot: actions: write (state cache), issues: write, pull-requests: write
@amaechler amaechler added Security Area - GitHub Actions Any GitHub Action change labels Nov 13, 2026
@github-actions github-actions Bot added the GHA label Nov 13, 2026
@amaechler amaechler self-assigned this Nov 13, 2026

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No actionable issues found. The seven changed workflows grant the token scopes required by their actions: checkout jobs use contents: read, paths-filter and the semantic PR check use pull-requests: read, the actions timeline uses actions: read, and the stale bot retains the write scopes required for its configured label, comment, close, and state-cache operations. The reusable-workflow call chain was traced to confirm that the caller passes pull-requests: read to the changes job while nested worker and Docker jobs remain read-only for repository contents.

Reviewed 7 of 7 changed files.

Validation: git diff --check 32384e0f5883987e5902d07aec25dc66450d7b1f 228083e9b5a96c85e778eadd7b1f58fc41c9439d passed. No build or test commands were run; this was a static review.


This is an automated review by Codex GPT-5.6 Luna(Max)

@FrankChen021 FrankChen021 added the Approval Recommended Used when AI completes a review and reports no findings label Nov 14, 2026
# Conflicts:
#	.github/workflows/ci.yml
#	.github/workflows/unit-and-integration-tests-unified.yml

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No actionable issues found in this review. The seven changed workflow files grant the scopes required by their actions, including the reusable CI caller/called workflow chain, checkout, paths filtering, actions timeline, artifact handling, and stale bot operations.

Reviewed 7 of 7 changed files. This was a static review; no build or test commands were run.


This is an automated review by Codex GPT-5.6-Luna(max)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approval Recommended Used when AI completes a review and reports no findings Area - GitHub Actions Any GitHub Action change GHA Security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants